<template>
    <div class="login">
        <div style="text-align: center">
            <h4 style="color: white;font-weight: 600;font-size: 40px; letter-spacing: 1.6vw; ">拐脚老火锅</h4>
            <h3 style="color: white;font-size: 140%;margin-top:1vw;font-weight: 500">GUAI JIAO LAO HUO GUO</h3>
            <div style="margin-top: 30px">
                <el-form class="login-form">
                    <el-form-item>
                        <el-input
                                v-model="form.account"
                                placeholder="账号"
                                prefix-icon="el-icon-user"
                                clearable
                                class="custom-input"
                        ></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-input
                                v-model="form.password"
                                type="password"
                                placeholder="密码"
                                prefix-icon="el-icon-lock"
                                suffix-icon="el-icon-view"
                                class="custom-input"
                        ></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-checkbox v-model="form.remember" class="custom-checkbox">记住密码</el-checkbox>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" :loading="isLoading" @click="_handleLogin" class="login-button">
                            登录
                        </el-button>
                    </el-form-item>
                </el-form>

            </div>
        </div>

    </div>
</template>
<script>
    import identify from '../../components/identify/Count.vue'
    import {setLocalStorageItem} from '@/utils/storage-helper'
    import BeautyInput from '@/components/beauty-input'
    import {login} from '@/services/model/login'
    import cryptoJs from 'crypto-js'

    export default {
        data() {
            return {
                form: {
                    account: '',
                    password: '',
                },
                // 验证码
                inputCode: '', // 输入的值
                expressValue1: '', // 表达式的值
                userInput: {
                    name: "账号",
                    icon: "iconfont iconyonghuming"
                },
                pwdInput: {
                    name: "密码",
                    icon: "iconfont iconmima-copy"
                },
                account: '',
                Verification: '',
                password: '',
                // true 密码可见  false 密码不可见
                isExportPwd: false,
                // true 显示错误提示  false关闭
                isShowErrorInfo: false,
                // true 显示忘记密码提示  false 关闭
                isShowForgetFix: false,
                // 接口正在请求
                isLoading: false,
            }
        },
        computed: {
            // 设置 密码是否可见时的 图标
            suffixIcon() {
                return this.isExportPwd ? 'el-icon-view' : 'iconfont iconeye'
            },
            // 设置  密码input的type类型
            pwdType() {
                return this.isExportPwd ? 'text' : 'password'
            },
            // 当账号、密码都有值时，才允许登录
            isAllowLogin() {
                return !!this.form.account && !!this.form.password
            }
        },
        components: {BeautyInput, identify},
        methods: {
            expressValueBtn(item) {
                this.expressValue1 = item
            },

//des加密

            // 处理登录
            async _handleLogin() {
                if (!this.isAllowLogin) return false
                this.isLoading = true
                try {
                    let {data} = await login(this.form)
                    console.log(data)
                    this.isLoading = false
                    setLocalStorageItem('password', this.form.password, 365)
                    setLocalStorageItem('USER_TOKEN', data.userinfo.token, 30)
                    setLocalStorageItem('userInfo', data, 1)
                    // 由于改为了sesstion登陆，等addRouter为 []时，在路由防卫中才会重新拉去数据
                   console.log(111122)
                    this.$router.replace('/seat')
                } catch (error) {
                    this.isLoading = false
                    this.inputCode = ''
                    this.form.password = ''
                }







            }

        },
        mounted() {
        }
    }
</script>

<style lang="less" scoped>
    .el-button--text {
        color: #4caf50;
    }

    .inputBox {
        width: 75%;
    }

    .login {
        position: relative;
        width: 100%;
        height: 100%;
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
      background: url("@/assets/loginBg.jpg");
      background-size: 100% 100%;
      background-repeat: no-repeat;


        .bk_fixed {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            z-index: 0;

            .el-image {
                background-repeat: repeat-x;
                width: 50%;
                height: 100%;
            }

            .el-image2 {
                transform: rotateY(180deg)


            }
        }

        #Mycanvas {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            z-index: 0;
        }

        .login_wrap {
            padding: 2px;
            /*左上角*/
            background: linear-gradient(to bottom,
            rgba(8, 238, 255, 0.6),
            rgba(8, 238, 255, 0.2),
            rgba(8, 238, 255, 0)) left top,
            linear-gradient(to right,
            rgba(8, 238, 255, 0.6),
            rgba(8, 238, 255, 0.2),
            rgba(8, 238, 255, 0)) left top,
                /*右上角*/ linear-gradient(to bottom,
            rgba(8, 238, 255, 0.6),
            rgba(8, 238, 255, 0.2),
            rgba(8, 238, 255, 0)) right top,
            linear-gradient(to left,
            rgba(8, 238, 255, 0.6),
            rgba(8, 238, 255, 0.2),
            rgba(8, 238, 255, 0)) right top,
                /*左下角*/ linear-gradient(to top,
            rgba(8, 238, 255, 0.6),
            rgba(8, 238, 255, 0.2),
            rgba(8, 238, 255, 0)) left bottom,
            linear-gradient(to right,
            rgba(8, 238, 255, 0.6),
            rgba(8, 238, 255, 0.2),
            rgba(8, 238, 255, 0)) left bottom,
                /*右下角*/ linear-gradient(to top,
            rgba(8, 238, 255, 0.6),
            rgba(8, 238, 255, 0.2),
            rgba(8, 238, 255, 0)) right bottom,
            linear-gradient(to left,
            rgba(8, 238, 255, 0.6),
            rgba(8, 238, 255, 0.2),
            rgba(8, 238, 255, 0)) right bottom;
            background-repeat: no-repeat;
            background-size: 2px 180px, 180px 2px;
            margin: 0 auto;
            width: 600px;
            height: 478px;

            background-color: rgba(13, 34, 52, 0.8);
            background-color: rgba(15, 70, 140, 0.5);
            border: 1px solid black;
            box-shadow: 0px 1px 24px 0px rgba(0, 0, 0, 0.2);
            box-shadow: rgb(11, 234, 235) 0px 0px 10px inset;
            border-radius: 5px;
            opacity: 0.9;
            padding-top: 20px;
            animation: fade_bottom 1.5s;
            @keyframes fade_bottom {
                from {
                    transform: translateY(30px);
                    opacity: 0.2;
                }
                to {
                    transform: translateY(0px);
                    opacity: 0.9;
                }
            }

            .title_wrap {
                position: relative;
                line-height: 50px;
                text-align: center;
                align-items: center;
                background: linear-gradient(to right, rgba(8, 238, 255, 0.6), rgba(8, 238, 255, 0.2), rgba(8, 238, 255, 0));
                /*background: linear-gradient(to right,rgba(15, 70, 140, 0.1), rgba(15, 70, 140, 1), rgba(15, 70, 140, 0.1));*/

                & > p {
                    font-size: 30px;
                    font-weight: bold;
                    color: #fff;
                }

                img {
                    width: 100%;
                }

                .main {
                    padding: 2px 0 0 16px;

                    h6 {
                        font-size: 21px;
                        font-family: PingFangSC-Medium, PingFang SC;
                        font-weight: 600;
                        color: #303133;
                        line-height: 29px;
                    }

                    p {
                        margin-top: 2px;
                        font-size: 12px;
                        transform: scale(0.916);
                        transform-origin: 0;
                        color: rgba(150, 153, 151, 1);
                        line-height: 16px;
                    }
                }
            }

            .login_info {
                margin-top: 10px;
                height: 24px;

                .info_wrap {
                    margin: 0 auto;
                    width: 264px;
                    height: 100%;
                    background: rgba(243, 94, 95, 0.2);
                    border-radius: 4px;
                    opacity: 0.9;
                    text-align: center;
                    font-size: 12px;
                    color: #F35E5F;
                    display: flex;
                    justify-content: center;
                    align-items: center;

                    .el-icon-info {
                        font-size: 16px;
                        margin-right: 8px;
                    }
                }
            }

            .form {
                padding: 0px 150px 0;

                .form_password {
                    margin-top: 23px;
                }
            }

            .btn {
                margin-top: 20px;
                width: 100%;
                height: 58px;
                text-align: center;

                .btn_login {
                    height: 100%;
                    width: 192px;
                    border-radius: 10px;
                    font-weight: 600;
                    font-size: 25px;
                    color: #ffffff;
                    background: red;
                    margin-top: -10px;
                    background: linear-gradient(to left, rgba(8, 238, 255, 1), rgba(8, 238, 255, 0.2), rgba(8, 238, 255, 0));
                    /*background: linear-gradient(to right, rgba(8, 238, 255, 0.6), rgba(8, 238, 255, 0.2), rgba(8, 238, 255, 0));*/

                    /*border: 2px solid rgba(216, 216, 216, 1);*/
                    cursor: not-allowed;
                    transition: background 0.28s;
                    opacity: 0.9;

                    &.allow {
                        border: none;
                        color: #ffffff;
                        background-color: green;
                        cursor: pointer;
                        opacity: 1;
                    }
                }
            }

            .forget {
                margin-top: 16px;
                text-align: center;

                .get_password {
                    color: #909399;
                    line-height: 20px;
                    font-size: 14px;
                    cursor: pointer;
                }
            }
        }

        .getpwd {
            position: fixed;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            z-index: 9999;

            .getpwd_bk {
                position: absolute;
                width: 100%;
                height: 100%;
                background: rgba(0, 0, 0, 0.5);
                z-index: -1;
            }

            .getwpd_wrap {
                position: absolute;
                right: 40.6%;
                top: 40%;
                width: 380px;
                height: 228px;
                background: #ffffff;
                box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.5);
                border-radius: 4px;
                text-align: center;

                .get_pwd-title {
                    margin-top: 40px;
                    font-size: 20px;
                    font-family: PingFangSC-Medium, PingFang SC;
                    font-weight: 600;
                    color: #303133;
                    line-height: 28px;
                }

                .get_wpd-info {
                    display: block;
                    margin-top: 10px;
                    font-size: 16px;
                    font-family: PingFangSC-Regular, PingFang SC;
                    font-weight: 400;
                    color: rgba(96, 98, 102, 1);
                    line-height: 22px;
                }

                .get_btn {
                    margin-top: 40px;
                    width: 312px;
                    height: 48px;
                    background: #2b73af;
                    border-radius: 4px;
                    cursor: pointer;
                    font-size: 19px;
                    color: #ffffff;
                }
            }
        }
    }

    .export_pwd {
        display: inline-block;
        margin-top: 11px;
        cursor: pointer;
        font-size: 14px;
    }

    .fade_error-enter-active, .fade_error-leave-active {
        transition: all 0.28s;
    }

    .fade_error-enter, .fade_error-leave-to /* .fade-leave-active below version 2.1.8 */ {
        opacity: 0 !important;
        transform: translateY(-10px);
    }

    .fade_animition {
        animation: fade_common 1s;
        @keyframes fade_common {
            from {
                transform: translateY(20px);
            }
            to {
                transform: translateY(0px);
            }
        }
    }
</style>
<style scoped>

    .login-container {
        width: 300px;
        margin: 100px auto;
        padding: 20px;
        background-color: #2c2c2c;
        border-radius: 8px;
    }

    .login-form {
        display: flex;
        flex-direction: column;
    }

    .custom-input /deep/.el-input__inner {
        background-color: transparent;
        border: 1px solid rgba(255, 255, 255, 0.5); /* 透明边框 */
        color: #fff;
    }

    .custom-input /deep/.el-input__inner::placeholder {
        color: rgba(255, 255, 255, 0.5); /* 透明占位符颜色 */
    }

    .custom-input .el-input__icon {
        color: rgba(255, 255, 255, 0.5); /* 图标颜色 */
    }

    .custom-checkbox {
        color: #fff;
    }

    .login-button {
        width: 100%;
        background-color: #ff6b00;
        border-color: #ff6b00;
        color: #fff;
    }
</style>